package com.bmps.springcloud.insuredmicroservice.service.underwrite.strategy.insurance;

import com.bmps.springcloud.insuredmicroservice.config.accept.ProductConfig;
import com.bmps.springcloud.insuredmicroservice.constant.accept.AcceptConstant;
import com.bmps.springcloud.insuredmicroservice.constant.accept.UnderWriteConstant;
import com.bmps.springcloud.insuredmicroservice.model.accept.resquest.*;
import com.bmps.springcloud.insuredmicroservice.model.underwrite.InsuredModel;
import com.bmps.springcloud.insuredmicroservice.repository.underwrite.coresystem.InsuredCoreRepository;
import com.bmps.springcloud.insuredmicroservice.util.accept.AcceptUtil;


/**
 * description:
 *
 * @author jackdaw
 * @date 2020-06-16 16:33
 */
public class Net006InsuranceStrategy implements InsuranceStrategy {
    @Override
    public InsuredModel checkInsuredRolesByRiskCode(AcceptRequestDataModel acceptRequestDataModel, InsuredCoreRepository insuredCoreRepository, ProductModel productModel, ProductConfig productConfig) {
        CustInfoModel custInfoModel = acceptRequestDataModel.getRequest().getCustInfo();
        //被保人信息
        InsurantModel insurantModel = AcceptUtil.getInsurantModelBySeq(productModel.getProdInsSeq(), custInfoModel.getInsurants().getInsurant());
        //1-6类投保
        if (!AcceptConstant.OCCUPATION_ONE_TO_SIX.contains(insurantModel.getOccupationType())) {
           return AcceptUtil.getInsuredResponse(UnderWriteConstant.UNDER_WRITE_FIAL_CODE,
                    String.format(UnderWriteConstant.UNDER_WRITE_NPGG0016_MESSAGE, insurantModel.getOccupationType()));
        }
        return AcceptUtil.getInsuredResponse(AcceptConstant.RESULT_SUCCESS_CODE, AcceptConstant.RESULT_SUCCESS_MESSAGE);
    }
}
